/*
 * @Author: 詹真琦(legendryztachi@gmail.com)
 * @Date: 2021-12-17 13:31:54
 * @LastEditors: 詹真琦(legendryztachi@gmail.com)
 * @LastEditTime: 2021-12-17 13:34:44
 * @FilePath: \code\other\secret\webpack.prod.js
 * @Description: 
 */

const path = require('path');
const merge = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const config = require('./wp.dev.conf.js');

module.exports = merge(config, {
  mode: 'production',
  optimization: {
    minimizer: [
      new UglifyJsPlugin({
        test: /\.js(\?.*)?$/i,
        cache: true,
        parallel: true,
        sourceMap: false,
        extractComments: false,
        uglifyOptions: {
          ie8: true,
          warnings: false,
          mangle: true,
          output: { ascii_only: true, comments: false },
          compress: { drop_debugger: true, drop_console: false }
        }
      })
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: 'css/[name].min.css'
    }),
    new CopyWebpackPlugin(
      [
        {
          from: path.resolve(__dirname, './static'),
          to: 'static'
        }
      ],
      { logLevel: 'error' }
    )
  ]
});